package com.ge.modules.sys.controller;

import com.ge.common.utils.PageUtils;
import com.ge.common.utils.Query;
import com.ge.common.utils.R;
import com.ge.modules.entity.TbOrderRefundEntity;
import com.ge.modules.sys.service.SysOrderRefundService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 订单退货
 * 
 * @author lanyonglin
 * @email www.baidu.com
 * @date 2018-04-11 17:28:43
 */
@RestController
@RequestMapping("/sys/orderrefund")
public class SysOrderRefundController {
	@Autowired
	private SysOrderRefundService sysOrderRefundService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("sysOrderrefund:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<TbOrderRefundEntity> tbOrderRefundEntityList = sysOrderRefundService.queryList(query);
		int total = sysOrderRefundService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(tbOrderRefundEntityList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("sysOrderrefund:info")
	public R info(@PathVariable("id") Integer id){
		TbOrderRefundEntity tbOrderRefundEntity = sysOrderRefundService.queryObject(id);
		
		return R.ok().put("tbOrderRefundEntity", tbOrderRefundEntity);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("sysOrderrefund:save")
	public R save(@RequestBody TbOrderRefundEntity tbOrderRefundEntity){
		sysOrderRefundService.save(tbOrderRefundEntity);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("sysOrderrefund:update")
	public R update(@RequestBody TbOrderRefundEntity tbOrderRefundEntity){
		sysOrderRefundService.update(tbOrderRefundEntity);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("sysOrderrefund:delete")
	public R delete(@RequestBody Integer[] ids){
		sysOrderRefundService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
